using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class web_Controls_page_center_tintuc : System.Web.UI.UserControl
{
    Common _common = null;
    public string type = "01";
    public Boolean home = false;
    protected void Page_Load(object sender, EventArgs e)
    {
        _common = new Common();
        home = Request.Url.AbsolutePath.Contains("web");
        home = !home;
        if (!string.IsNullOrEmpty(this.SkinID.ToString())) type = _common.TextFormat(this.SkinID.ToString()).Trim();
        LoadNewsMain();
    }


    public string _ma = "";
    public string _hinh = "";
    public string _tieude = "";
    public string _motangan = "";
    public string _tintuc = "";

    void LoadNewsMain()
    {
        string _sql = "select top 4 A.*,B.ten_loai_tin_tuc from TinTuc_tin_tuc as A inner join TinTuc_loai_tin_tuc as B"+
            " on A.ma_loai_tin_tuc=B.ma_loai_tin_tuc " +
            " where A.ma_loai_tin_tuc = '"+type+"' and A.kich_hoat = 1 order by convert(datetime, A.ngay_tao) desc";
        DataSet _ds = _common.ExeceuteDataset(_sql);
        rpt_news_main.DataSource = _ds;
        rpt_news_main.DataBind();
        if (_ds.Tables[0].Rows.Count > 0)
        {
            _ma = _ds.Tables[0].Rows[0]["ma_tin_tuc"].ToString();
			if(home){
				_hinh = _ds.Tables[0].Rows[0]["tep_tin"].ToString();
			}else{
				_hinh ="../../"+ _ds.Tables[0].Rows[0]["tep_tin"].ToString();
			}
            _tieude = _ds.Tables[0].Rows[0]["tieu_de"].ToString();
            _motangan = _ds.Tables[0].Rows[0]["mo_ta_ngan"].ToString();
            _tintuc = _ds.Tables[0].Rows[0]["ten_loai_tin_tuc"].ToString();
            if (_motangan.Length > 800)
            {
                _motangan = _motangan.Substring(0, 800);
            }
        }
    }
}
